<!DOCTYPE html>
<html>
<head>
    <title>模块详情</title>
    <link href="__PLUGIN_TMPL__/public/assets/layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="__PLUGIN_TMPL__/public/assets/layui/css/backend.min.css" rel="stylesheet" type="text/css">
    <include file='public/head'>
        <style>
            table th, table td{text-align: center;}
            .ml-10 { margin-left: 10px; }
			.layui-icon{font-size: 14px !important;}
			.layui-form-label{ width: auto;}
			.layui-btn.layui-btn-sm .fa{ font-size: 14px !important;}
			.mr4{ margin-right: 4px;}
			.layui-form-item{ margin-bottom: 0px;}
			.row{ margin: 0 !important;}
			.form-horizontal .form-group { margin: 0 0 15px 0}
        </style>
</head>
<body>
	<div class="wrap js-check-wrap" style="padding: 20px 20px 0px 20px;">
	    <ul class="nav nav-tabs">
	        <php> $currentTab = 5 ;</php>
	        <include file="public/nav" />
	    </ul>
	    <div class="well margin-top-20">
			<div id="moduleDevolopProcess"></div>
		</div>
	</div>
    <div id="main" role="main">
        <div class="tab-content tab-addtabs">
			<div id="content">
				<div class="row">
					<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
						<div class="content">
							<form id="edit-form" class="form-horizontal nice-validator n-default n-bootstrap" style="padding-bottom: 150px;">
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">模块标识:</label>
									<div class="col-xs-12 col-sm-8">
										<input class="form-control" id="module-symbol" name="name" type="text"   value="{$module.name|default=''}" placeholder="请填写模块英文名(大驼峰命名，如：ModuleConfig)" autocomplete="off" required>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">模块名:</label>
									<div class="col-xs-12 col-sm-8">
										<input class="form-control" id="module-name"   name="title" type="text"  value="{$module.title|default=''}" placeholder="请填写模块中文名" required>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">模块简介:</label>
									<div class="col-xs-12 col-sm-8">
										<input class="form-control"   name="describe" type="text"  value="{$module.describe|default=''}" placeholder="请填写模块简介信息" required>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">模块功能介绍:</label>
									<div class="col-xs-12 col-sm-8">
										<textarea class="form-control"  rows='3' name="introduce"  placeholder="请填写模块简介信息" required>{$module.introduce|default=''}</textarea>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">温馨提醒:</label>
									<div class="col-xs-12 col-sm-8">
										<textarea class="form-control"  rows='3' name="warning"   placeholder="请填写模块简介信息" required>{$module.warning|default=''}</textarea>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">价格:</label>
									<div class="col-xs-12 col-sm-8">
										<input type="number" name="price" class="form-control" value="{$module.price|default='0'}" placeholder="请填写价格" />
									</div>
								</div>
								<div class="form-group">
									<label for="c-keywords" class="control-label col-xs-12 col-sm-2">版本号:</label>
									<div class="col-xs-12 col-sm-8">
										<input id="c-keywords" class="form-control" name="version" type="text" value="{$module.version|default='1.0'}" autocomplete="off"  required placeholder="请将数据填写版本号">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">模块预览图:</label>
									<div class="col-xs-12 col-sm-8">
										<ul class="row list-inline plupload-preview" id="images_list">
											<volist name="previewList" id="vo">
												<li class="col-xs-3"><a href="/<?php echo $previewList[$key] ; ?>" data-url="#" target="_blank" class="thumbnail"><img src="/<?php echo $previewList[$key] ; ?>" alt="00" class="img-responsive"></a></li>
											</volist>
										</ul>
									</div>
								</div>
								<div class="form-group">
									<label for="c-keywords" class="control-label col-xs-12 col-sm-2">思维导图URL:</label>
									<div class="col-xs-12 col-sm-8">
										<p class="form-control-static"><span class="glyphicon glyphicon-globe"></span>&nbsp;<a href="{$module.mind_map_url|default='javascript:;'}" target="_blank">{$module.mind_map_url|default='无记录~'}</a></p>
									</div>
								</div>
								<div class="form-group">
									<label for="c-keywords" class="control-label col-xs-12 col-sm-2">流程图URL:</label>
									<div class="col-xs-12 col-sm-8">
										<p class="form-control-static"><span class="glyphicon glyphicon-globe"></span>&nbsp;<a href="{$module.flow_chart_url|default='javascript:;'}"  target="_blank">{$module.flow_chart_url|default='无记录~'}</a></p>
									</div>
								</div>
								<div class="form-group">
									<label for="c-keywords" class="control-label col-xs-12 col-sm-2">UI设计图URL:</label>
									<div class="col-xs-12 col-sm-8">
										<p class="form-control-static"><span class="glyphicon glyphicon-globe"></span>&nbsp;<a href="{$module.ui_url|default='javascript:;'}"  target="_blank">{$module.ui_url|default='无记录~'}</a></p>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">思维导图文件:</label>
									<div class="col-xs-12 col-sm-8">
										<div class="input-group">
											<if condition="$address['main']['status'] eq 1">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="{$address['main']['address']}/{$module.mind_map|default='javascript:;'}" download="{$address['main']['address']}/{$module.mind_map|default='javascript:;'}">(主地址)'思维导图文件下载</a></p>
											</if>
											<if condition="$address['minor']['status'] eq 1">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="{$address['minor']['address']}/{$module.mind_map|default='javascript:;'}" download="{$address['minor']['address']}/{$module.mind_map|default='javascript:;'}">(备用地址)思维导图文件下载</a></p>
											</if>
										</div>
										<ul class="row list-inline plupload-preview" id="image_list"></ul>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">流程图文件:</label>
									<div class="col-xs-12 col-sm-8">
										<div class="input-group">
											<if condition="$address['main']['status'] eq 1">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="{$address['main']['address']}/{$module.flow_chart|default='javascript:;'}" download="{$address['main']['address']}/{$module.flow_chart|default='javascript:;'}">(主地址)流程图文件下载</a></p>
											</if>
											<if condition="$address['minor']['status'] eq 1">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="{$address['minor']['address']}/{$module.flow_chart|default='javascript:;'}" download="{$address['minor']['address']}/{$module.flow_chart|default='javascript:;'}">(备用地址)流程图文件下载</a></p>
											</if>
										</div>
										<ul class="row list-inline plupload-preview" id="image_list"></ul>
									</div>
								</div>
								
								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">UI设计图文件:</label>
									<div class="col-xs-12 col-sm-8">
										<div class="input-group">
											<if condition="$address['main']['status'] eq 1">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="{$address['main']['address']}/{$module.ui|default='javascript:;'}" download="{$address['main']['address']}/{$module.ui|default='javascript:;'}">(主地址)UI设计图文件下载</a></p>
											</if>
											<if condition="$address['minor']['status'] eq 1">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="{$address['minor']['address']}/{$module.ui|default='javascript:;'}"  download="{$address['minor']['address']}/{$module.ui|default='javascript:;'}">(备用地址)UI设计图文件下载</a></p>
											</if>
										</div>
										<ul class="row list-inline plupload-preview" id="image_list"></ul>
									</div>
								</div>

								<div class="form-group">
									<label class="control-label col-xs-12 col-sm-2">模块源文件(压缩包):</label>
									<div class="col-xs-12 col-sm-8">
										<div class="input-group">
											<if condition="$address['main']['status'] eq 1 and !empty( $module[ 'resource' ] )">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="\{$address['main']['address']}/{$module.resource|default='javascript:;'}" download="{$address['main']['address']}/{$module.resource|default='javascript:;'}">(主地址)模块源文件下载</a></p>
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="javascript:;" data-ul="{$module['resource']}" onclick="getFile( this,1, '12.zip' );">(主地址)模块源文件下载</a></p>
											</if>
											<if condition="$address['minor']['status'] eq 1">
												<p class="form-control-static"><span class="glyphicon glyphicon-download-alt"></span>&nbsp;<a href="{$address['minor']['address']}/{$module.resource|default='javascript:;'}" download="{$address['minor']['address']}/{$module.resource|default='javascript:;'}">(备用地址)模块源文件下载</a></p>
											</if>
										</div>
										<ul class="row list-inline plupload-preview" id="image_list"></ul>
									</div>
								</div>

								<div class="form-group" style="display: none;">
									<input type="hidden" id="audit-id" name="" value="{$module.id|default=0}">
									<label for="c-keywords" class="control-label col-xs-12 col-sm-2">操作:</label>
									<div class="col-xs-12 col-sm-8">
										<a href="javascript:;" class="btn btn-primary" onclick="formData(this,'save');"><span class="glyphicon glyphicon-floppy-disk"></span>保存</a>
										<a href="javascript:;" class="btn btn-success" onclick="formData(this,'audit');"><span class="glyphicon glyphicon-saved"></span>提交审核</a>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
    <include file='public/scripts'>
	<script src="__PLUGIN_TMPL__/public/assets/layui/layui.all.js"></script>
	<script src="__STATIC__/js/custom/custom.js"></script>
<script type="text/javascript">
var method = {};
$(function(){
	layui.use('upload', function(){
		var $ = layui.jquery
		,upload = layui.upload;

		//上传思维导图
		upload.render({ 
			elem: '#mindMap'
			,url: "{:cmf_plugin_url('Appmarket://publish/mindMap')}"
			,accept: 'file' //普通文件
			,exts: "zip|rar" //只允许上传压缩文件
			,done: function( res ){
				showMessage( res, 'mind_map' , '#mindMap' );				
			}
		});

		//上传流程图
		upload.render({ 
			elem: '#flowChart'
			,url: "{:cmf_plugin_url('Appmarket://publish/flowChart')}"
			,accept: 'file' //普通文件
			,exts: "zip|rar" //只允许上传压缩文件
			,done: function( res ){
				showMessage( res , 'flow_chart' , '#flowChart' );				
			}
		});

		//上传ui图
		upload.render({ 
			elem: '#uiMap'
			,url: "{:cmf_plugin_url('Appmarket://publish/uiMap')}"
			,accept: 'file' //普通文件
			,exts: "zip|rar" //只允许上传压缩文件
			,done: function( res ){
				showMessage( res , 'ui' , '#uiMap' );				
			}
		});

		var showMessage = function( data , inputName , id ){
			var icon  = (data.code == 200 )? 1: 5;
			layer.msg( data.message , { icon: icon });
			if( icon == 1 ){
				$('input[name='+inputName+']').val(data.data);
			}
		}
	});
});	

</script>

<script type="text/javascript"> 
	var formData = function( _this , type ){
		var formData = $($('#edit-form').serializeArray());
		var tmp = {};
		var flag = true;
		var message = '请将数据填写完整后再提交！';
		$.each(formData,function( index , value ){
			$('[name='+value.name+']').css('border','');
			if( $.trim( value.value ) == ""  &&  ( $('[name='+value.name+']').attr('required') != undefined )  ){
				$('[name='+value.name+']').css('border','1px solid red');
				flag = false;
				message = $('[name='+value.name+']').attr('placeholder');
				return false;
			}
			tmp [ value.name ] = value.value;
		});
		if( !isOk || !flag ){
			layer.msg( message );
			return false;
		}
		var id = $('#audit-id').val();
		if( type == "audit" && id == 0 ){
			layer.msg('请先保存后再提交审核！');
			return false;
		}
		banBtn(_this);
		//提交数据
		$.post( "{:cmf_plugin_url('Appmarket://publish/stepOnePost')}" , {id:id,type:type,data:tmp} ,function(data){
			console.log(data);
			var icon  = ( data.code == 200 ) ? 1 : 5;
			layer.msg( data.message , { icon : icon });
			if( data.code == 200 ){
				if( data.data.res == 'id' ){
					//数据保存成功
					$('#audit-id').val(data.data.id);
				}else if( data.data.res == 'url' ){
					//跳转页面到申请结果页面
					setTimeout(function(){
						window.location.href = data.data.url;
					}, 1200);
				}
			}
			cancelBan(_this);
		},'json')
	}

//模块菜单验证
var isRequest = false;
var isOk = true;
var checkModuleMenu = function(_this){
	var moduleName = $('#module-name').val();
	var moduleSymbol = $('#module-symbol').val();
	var url = "{:cmf_plugin_url('Appmarket://publish/checkModuleMenu')}";
	if( isRequest ){ return false; }
	isRequest = true;
	$('input[name=name]').removeAttr('');
	$('input[name=name]').val('');
	$.post( url , {moduleName:moduleName,moduleSymbol:moduleSymbol} , function(data){
		var color = "color:#9FE059";
		isOk = (data.code == 200 ) ;
		if( data.code != 200 ){
			color = "color:red;";
		}
		if( data.code == 200 && !(data.data == undefined) ){
			$('input[name=name]').attr('',true);
			$('input[name=name]').val(data.data);
		}	
		var warning = '<span style="'+color+'">'+data.message+'</span>';
		$(_this).siblings().remove();
		$(_this).after(warning);
		isRequest = false;
		console.log("cmm->:"+isOk);
	} ,'json' );
};

//版本号验证
var checkVersionNumber = function(_this){
	var reg = /^\d+(\.\d+)+$/;
	var versionStr = $(_this).val();
	var flag = true;
	if( false == reg.test( versionStr ) ){
		flag = false;
		var message = "版本号格式错误，请检查！";
		if( $.trim( versionStr ) == '' ){
			message = "请填写版本号！";
		}
		var warning = '<span style="color:red;">'+message+'</span>';
		$(_this).siblings().remove();
		$(_this).after(warning);
	}else{ 
		$(_this).siblings().remove();
	}
	isOk = ( isOk && flag );
}


var getFile = function(_this,type , title){
	var url = $(_this).data('ul');
	window.open('{:cmf_plugin_url("Appmarket://audit/getFiles")}?url='+url+'&tle='+title+'&type='+type);
}
</script>

<script type="text/javascript">

</script>
</body>
</html>

